package gui.MatchPointDialogue;

import gui.Error.ErrorDialogue;
import gui.Error.TextToIntException;

import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JDialog;

import core.Team;

public class MatchPointDialog extends JDialog implements ActionListener{

	private RefreshClassement rc;
	private static final long serialVersionUID = -4648361156548329752L;
	private MatchPointPanel mpp;
	public MatchPointDialog(Frame frame,RefreshClassement refreshClassement) {
		super(frame,true);
		mpp=new MatchPointPanel(this);
		setContentPane(mpp);
		pack();
		setResizable(false);
		setLocationRelativeTo(frame);
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		rc=refreshClassement;
		setVisible(true);
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		try {
			int[] p=mpp.matchPoint();
			Team.NB_WIN_POINT=p[0];
			Team.NB_NULL_POINT=p[1];
			Team.NB_LOOSE_POINT=p[2];
			rc.refreshClassement();
			dispose();
		} catch (TextToIntException e1) {
			new ErrorDialogue(this,e1.getMessage());
		}
		
	}




}
